package com.huangjue.backend.mapper;

import com.huangjue.backend.entity.Submission;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;

public interface SubmissionMapper {
    // 插入新提交
    int insert(Submission submission);

    // 根据ID查询提交
    Submission selectById(@Param("submissionId") Integer submissionId);

    // 根据作业ID查询所有提交
    List<Submission> selectByHomeworkId(@Param("homeworkId") Integer homeworkId);

    // 更新提交内容
    int updateContent(@Param("submissionId") Integer submissionId,
                      @Param("content") String content,
                      @Param("submissionTime") Date submissionTime);

    // 删除提交
    int deleteById(@Param("submissionId") Integer submissionId);

    // 根据用户和作业查询提交
    List<Submission> selectByUserAndHomework(@Param("userId") Integer userId,
                                             @Param("homeworkId") Integer homeworkId);

    // 根据作业ID和用户ID查询提交记录
    Submission selectByHomeworkIdAndUserId(
            @Param("homeworkId") Integer homeworkId,
            @Param("userId") Integer userId);

    // 根据用户ID查询所有提交记录
    List<Submission> selectByUserId(@Param("userId") Integer userId);
}